<template>
  <div class="personal-main">
    <el-table :data="investList" stripe style="width: 100%">
      <el-table-column prop="lendItemNo" label="投资编号"> </el-table-column>
      <el-table-column prop="investAmount" label="投资金额"> </el-table-column>
      <el-table-column label="年化率">
        <template slot-scope="scope">
          {{ scope.row.lendYearRate * 100 }}%
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="投资时间"> </el-table-column>
      <el-table-column prop="expectAmount" label="预期收益"> </el-table-column>
      <el-table-column prop="lendStartDate" label="开始日期"> </el-table-column>
      <el-table-column prop="lendEndDate" label="结束日期"> </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-tag size="mini" v-if="scope.row.status === 1">
            {{ "已支付" }}
          </el-tag>
          <el-tag size="mini" type="success" v-if="scope.row.status === 2">
           已还款
          </el-tag>
        </template>
      </el-table-column>
      <!--<el-table-column label="操作">-->
      <!--  <template slot-scope="scope">-->
      <!--    <el-button-->
      <!--      size="mini"-->
      <!--      type="success"-->
      <!--      v-if="scope.row.status === 1"-->
      <!--      @click="handleCancel(scope.$index, scope.row)"-->
      <!--    >-->
      <!--      撤销申请-->
      <!--    </el-button>-->
      <!--    &lt;!&ndash;<el-tag size="mini">{{ scope.row.param.status }}</el-tag>&ndash;&gt;-->
      <!--  </template>-->
      <!--</el-table-column>-->
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="pageNum"
      :page-size="pageSize"
      style="padding: 30px 0; text-align: center"
      layout="total, sizes, prev, pager, next, jumper"
      :page-sizes="[2,1, 10, 20]"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageNum: 1,
      pageSize: 3,
      investList: [],
      total: 0,
    };
  },
  mounted() {
    this.initData();
  },
  methods: {
    handleSizeChange(size) {
      this.pageSize = size;
      this.initData();
    },
    handleCurrentChange(num) {
      this.pageNum = num;
      this.initData();
    },
    initData() {
      let token = localStorage.getItem("FINANCE-TOKEN");
      if (!token) {
        this.$message.error("请先登录");
        return;
      }
      this.$axios({
        url: `/core/api/lendItem/list`,
        method: "GET",
        headers: { token },
      }).then((response) => {
        console.log(response.data);
        this.investList = response.data.data
        this.total = Number(response.data.data.total);
      });
    },
  },
};
</script>
